<?php
/**
 * Short Description  
 *
 * Long Description 
 *
 * @copyright 
 * @version   $Id: ResourceModuleDAO.php 12 2011-04-09 08:58:51Z sandeep.manne@gmail.com $
 */

require_once 'Core/DAO.php';

class ResourceModuleDAO extends Core_DAO
{
	protected $_name    = 'resource_module';
	protected $_primary = 'module_id';
	
	public function addModule($moduleName)
	{
		if ($this->getModuleByName($moduleName) == null) {
			return $this->insert(array("module_name" => $moduleName));
		} else {
			return null;
		}
	}
	
	
	public function getAllModules()
	{
		return $this->select()
			 		->from($this->_name)
			 		->query()
			 		->fetchAll();
	}
	
	public function getModuleByName($moduleName)
	{
		$module =  $this->select()
						->from($this->_name)
						->where("module_name = ?", $moduleName)
						->query()
						->fetchAll();
					
		return $module[0];
	}
}